cmake_minimum_required(VERSION 3.8)
project(autoaim)

if (NOT CMAKE_CXX_STANDARD)
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
endif ()

add_compile_definitions(PROJECT_DIR="${PROJECT_SOURCE_DIR}/..")

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(OpenCV REQUIRED)
find_package(interfaces REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(image_transport REQUIRED)
find_package(Ceres REQUIRED)
# find_package(visualization_msgs REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})


if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

file(GLOB_RECURSE sourcefiles1 "src/*.cpp")
file(GLOB_RECURSE sourcefiles2 "../tool/src/*.cpp")

add_executable(auto_aim ${sourcefiles1} ${sourcefiles2})
ament_target_dependencies(auto_aim rclcpp)

ament_target_dependencies(
  auto_aim
  "rclcpp"
  "interfaces"
  cv_bridge
  image_transport
  Ceres
  # visualization_msgs
)

install(TARGETS
  auto_aim
  DESTINATION lib/${PROJECT_NAME}
)

target_link_libraries(auto_aim
        # ${InferenceEngine_LIBRARIES}
        # ${NGRAPH_LIBRARIES}
        ${OpenCV_LIBS}
        # visualization_msgs
        # -pthread
        ${CERES_LIBRARIES}
        # Eigen3::Eigen
        # fmt::fmt
        # /lib/libMVSDK.so
       # ${CSPARSE_LIBRARY}
       # g2o_core g2o_stuff g2o_types_sba g2o_csparse_extension g2o_types_slam3d g2o_solver_csparse
        )

        
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}
)
ament_package()
